﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using NoteHelper.IBusiness;
using NoteHelper.Model;

namespace NoteHelper.Business.IbatisImpl
{
    public class ProjectFormManagerImpl : ManagerBase<ProjectForm>, IProjectFormManager
    {
        public DataTable Query(Hashtable ht)
        {
            LogRuntimeSql("CustomQueryProjectForm", ht);
            var lst = Mapper.QueryForList<ProjectForm>("CustomQueryProjectForm", ht);
            var fields = new[] { "ObjectID", "Description", "FullName", "UpdateAt", "UpdateUser" };
            var table = lst.ToDataTable(fields);
            table.Columns.Add("$_rowIndex", typeof(int));
            for (int i = 0; i < table.Rows.Count; i++)
            {
                var row = table.Rows[i];
                row["$_rowIndex"] = i;
            }
            return table;
        }

        public IList<ProjectForm> GetList(string className)
        {
            Hashtable ht = new Hashtable();
            ht.Add("ObjectID", className);
            LogRuntimeSql("CustomQueryProjectForm", ht);
            var lst = Mapper.QueryForList<ProjectForm>("CustomQueryProjectForm", ht);
            return lst;
        }
    }
}
